﻿using Cms.Domain.RepositoryInterfaces;

namespace Cms.Data
{
    public class RepositoryFactory : IRepositoryFactory
    {
        private IAdministratorRepository _administratorRepository;
        private ICategoryRepository _categoryRepository;
        private IContentRepository _contentRepository;
        private IFolderRepository _folderRepository;
        private ILocaleRepository _localeRepository;
        private IMediaRepository _mediaRepository;
        private IPageRepository _pageRepository;
        private ISiteRepository _siteRepository;
        private ISystemRepository _systemRepository;
        private IUserRepository _userRepository;
        private IPermissionRepository _permissionRepository;

        #region IRepositoryFactory Members

        public ISiteRepository SiteRepository
        {
            get
            {
                if (_siteRepository != null)
                    return _siteRepository;
                _siteRepository = new SiteRepository();
                return _siteRepository;
            }
        }

        public ILocaleRepository LocaleRepository
        {
            get
            {
                if (_localeRepository != null)
                    return _localeRepository;
                _localeRepository = new LocaleRepository();
                return _localeRepository;
            }
        }
        
        public IPageRepository PageRepository
        {
            get
            {
                if (_pageRepository != null)
                    return _pageRepository;
                _pageRepository = new PageRepository();
                return _pageRepository;
            }
        }

        public IFolderRepository FolderRepository
        {
            get
            {
                if (_folderRepository != null)
                    return _folderRepository;
                _folderRepository = new FolderRepository();
                return _folderRepository;
            }
        }
        
        public IAdministratorRepository AdministratorRepository
        {
            get
            {
                if (_administratorRepository != null)
                    return _administratorRepository;
                _administratorRepository = new AdministratorRepository();
                return _administratorRepository;
            }
        }

        public ICategoryRepository CategoryRepository
        {
            get
            {
                if (_categoryRepository != null)
                    return _categoryRepository;
                _categoryRepository = new CategoryRepository();
                return _categoryRepository;
            }
        }

        public IContentRepository ContentRepository
        {
            get
            {
                if (_contentRepository != null)
                    return _contentRepository;
                _contentRepository = new ContentRepository();
                return _contentRepository;
            }
        }

        public IMediaRepository MediaRepository
        {
            get
            {
                if (_mediaRepository != null)
                    return _mediaRepository;
                _mediaRepository = new MediaRepository();
                return _mediaRepository;
            }
        }

        public ISystemRepository SystemRepository
        {
            get
            {
                if (_systemRepository != null)
                    return _systemRepository;
                _systemRepository = new SystemRepository();
                return _systemRepository;
            }
        }

        public IUserRepository UserRepository
        {
            get
            {
                if (_userRepository != null)
                    return _userRepository;
                _userRepository = new UserRepository();
                return _userRepository;
            }
        }

        public IPermissionRepository PermissionRepository
        {
            get
            {
                if (_permissionRepository != null)
                    return _permissionRepository;
                _permissionRepository = new PermissionRepository();
                return _permissionRepository;
            }
        }

        #endregion
    }
}